﻿using System.Linq;
using Daemon.Common;
using Daemon.Common.Helpers;
using Daemon.Infrustructure.EF;
using Daemon.Repository.EF.Enums;
using Daemon.Repository.Contract;
using Daemon.Model;
using System;
using System.Linq.Expressions;
using System.Collections.Generic;

namespace Daemon.Repository.EF
{
	public class TakeAwayAccountTransactionRepository : Repository<TakeAwayAccountTransaction>, ITakeAwayAccountTransactionRepository
	{
		protected override Expression<Func<TakeAwayAccountTransaction, int>> PrimaryKeyExpression => r => r.Id;

		public TakeAwayAccountTransactionRepository(ApiDBContent context) : base(context)
		{
		}

		protected override void UpdateEntitiesBeforeCreate(IEnumerable<TakeAwayAccountTransaction> entities, ApiDBContent context)
		{
			foreach (var entity in entities)
			{
				entity.PayTime = DateTime.Now;
			}

			base.UpdateEntitiesBeforeCreate(entities, context);
		}
	}
}
